<script setup>
// import HomePanel from './HomePanel.vue'
import { ref, onMounted } from 'vue'
import { getGoodsProductAPI } from '@/apis/home'
// import GoodsItem from '@/components/GoodsItem.vue'
import { imageBaseURL } from '@/utils/request'
// 获取热门品牌数据
const goodsProductList = ref([])
const getGoodsProduct = async () => {
  const res = await getGoodsProductAPI()
  goodsProductList.value = res.result
}

onMounted(() => getGoodsProduct())
</script>

<template>
  <div class="home-product">
      <h3>--商品列表--</h3>
        <ul class="goods-list">
          <li v-for="good in goodsProductList" :key="good.id">
            <RouterLink :to="`/detail/${good.id}`">
              <img v-img-lazy="imageBaseURL + good.picture" alt="" />
              <p class="name">{{ good.name }}</p>
              <p class="desc">{{ good.description }}</p>
              <p class="price">&yen;{{ good.price }}</p>
            </RouterLink>
          </li>
        </ul>
  </div>
</template>

<style scoped lang="scss">
// .home-panel {
//   backdrop-filter: red;
//   h3 {
//     text-align: center;
//   }
// }
h3 {
      flex: 1;
      font-size: 32px;
      font-weight: normal;
      height: 35px;
      line-height: 35px;
      text-align: center;;
      margin-bottom: 30px;

}
.home-product {
  background: #f3f4f5;
  margin-top: 20px;
  padding: 20px 0;



  .goods-list {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 0 15px;

    li {
      background: #ffffff;
      border: 1px solid #e7e7e7;
      border-radius: 5px;
      padding: 10px;
      transition: all 0.3s;

      &:hover {
        transform: translate3d(0, -3px, 0);
        box-shadow: 0 3px 8px rgb(0 0 0 / 10%);
      }

      img {
        width: 100%;
        height: 160px;
        object-fit: cover;
        border-radius: 4px;
      }

      p {
        font-size: 14px;
        padding: 6px 0;
        text-align: left;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
      }

      .price {
        color: $priceColor;
        font-size: 22px;
        font-weight: bold;
        margin-top: 8px;
        position: relative;
        padding-left: 50px;

        &::before {
          content: '特卖价';
          position: absolute;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          display: inline-block;
          width: 45px;
          height: 18px;
          background-image: repeating-linear-gradient(90deg, #dc459f 0, #cc75d8 100%);
          color: #ffffff;
          font: 12px/18px "微软雅黑";
          text-align: center;
          border-radius: 9px;
        }
      }
    }
  }
}
.desc {
  color: #999;
}
</style>